package com.wz.common.bas.taskNoUtils.controller;

import java.util.List;

import com.wz.common.bas.taskNoUtils.domain.BasTaskNo;
import com.wz.common.bas.taskNoUtils.service.IBasTaskNoService;
import com.wz.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;

import com.wz.framework.web.page.TableDataInfo;

/**
 * 任务号Controller
 * 
 * @author qxq
 * @date 2021-11-05
 */
@Controller
@RequestMapping("/任务号/taskNoUtils")
public class BasTaskNoController extends BaseController
{
    private String prefix = "任务号/taskNoUtils";

    @Autowired
    private IBasTaskNoService basTaskNoService;

//    @RequiresPermissions("任务号:taskNoUtils:view")
    @GetMapping()
    public String taskNoUtils()
    {
        return prefix + "/taskNoUtils";
    }

    /**
     * 查询任务号列表
     */
//    @RequiresPermissions("任务号:taskNoUtils:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasTaskNo basTaskNo)
    {
        startPage();
        List<BasTaskNo> list = basTaskNoService.selectBasTaskNoList(basTaskNo);
        return getDataTable(list);
    }

    /**
     * 导出任务号列表
     */
    @RequiresPermissions("任务号:taskNoUtils:export")
    @Log(title = "任务号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BasTaskNo basTaskNo)
    {
        List<BasTaskNo> list = basTaskNoService.selectBasTaskNoList(basTaskNo);
        ExcelUtil<BasTaskNo> util = new ExcelUtil<BasTaskNo>(BasTaskNo.class);
        return util.exportExcel(list, "taskNoUtils");
    }

    /**
     * 新增任务号
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存任务号
     */
    @RequiresPermissions("任务号:taskNoUtils:add")
    @Log(title = "任务号", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BasTaskNo basTaskNo)
    {
        return toAjax(basTaskNoService.insertBasTaskNo(basTaskNo));
    }

    /**
     * 修改任务号
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        BasTaskNo basTaskNo = basTaskNoService.selectBasTaskNoById(id);
        mmap.put("basTaskNo", basTaskNo);
        return prefix + "/edit";
    }

    /**
     * 修改保存任务号
     */
    @RequiresPermissions("任务号:taskNoUtils:edit")
    @Log(title = "任务号", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BasTaskNo basTaskNo)
    {
        return toAjax(basTaskNoService.updateBasTaskNo(basTaskNo));
    }

    /**
     * 删除任务号
     */
    @RequiresPermissions("任务号:taskNoUtils:remove")
    @Log(title = "任务号", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basTaskNoService.deleteBasTaskNoByIds(ids));
    }
}
